<!DOCTYPE html>
[#escape x as (x)!?html]
<html lang="zh-CN">
  <head>
    <meta charset="utf-8" />
    <title>我的信件 - ${site.seoTitle} - Powered by JPROCMS</title>
    [#include '../includes/common_res.html'/]
    <link
      rel="stylesheet"
      href="${resource}/static/plugins/flatpickr/dist/flatpickr.min.css"
    />
    <script src="${resource}/static/plugins/flatpickr/dist/flatpickr.min.js"></script>
    <script src="${resource}/static/plugins/flatpickr/dist/l10n/index.js"></script>
  </head>
  <body>
    [#assign shadowNav=true/] [#include '../includes/header.html'/]
    <div class="container mt-3">
      <div class="row">
        <div class="col-sm-3">
          <div class="list-group mt-2">
            [#assign settings = 'member-letter'/] [#include 'user_left.html'/]
          </div>
        </div>
        <div class="col-sm-9">
          <h3 class="py-3 border-bottom">我的信件</h3>
          [#if loginUser??]
          [@ZLetterPage  userId=loginUser.id  pageSize='10';pageResult]
          <ul class="list-unstyled">
            [#list pageResult.list as letter]
              <li class="mt-3 pb-3 border-bottom position-relative">
                <div class="d-flex align-items-center">
                  <div class="badge badge-info mr-2">${letter.typeName}</div>
                  <div class="flex-grow-1 text-truncate col-6"><a id="letter-${letter.id}" href="${base}/letter/my/${letter.id?c}" class="text-reset stretched-link">${letter.title!ZSubstring(g.letterText,100,'...')}</a></div>
                  <div class="text-black-50 col-2 ">
                    <div> [#if letter.replyDeptName??]${letter.replyDeptName}[#else]等待办理中[/#if]</div>
                  </div>
                  <div class="text-black-50 col-4 ">
                    <div ><i class="ml-2 far fa-clock"></i> 
                      [#if letter.replyDate??]${ZFormat(letter.replyDate, 'yyyy-MM-dd HH:mm:ss')}[#else]等待办理中[/#if]
                    
                      <span class="flex-grow-1 text-truncate mr-0"><a id="letterdel-${letter.id}" href="${base}/letter/delete/${letter.id?c}" class="text-reset stretched-link">删除</a></span>
                    </div>
                  
                  </div>
                </div>
              </li>
            [/#list]
          </ul>
          [#include '../includes/inc_page.html'/]
        [/@ZLetterPage]
        [/#if]
        </div>
      </div>
    </div>
    [#include '../includes/footer.html'/] [#include '../includes/inc_msg.html'/]
    <script>
      $(function () {
        Cms.getLoginUser("${base}", "${api}", false, loginedCallBack);
        const token = sessionStorage.getItem("accessToken")
        const link = $("#letter").attr("href")
        $('a[id^="letter-"]').attr('href', function(index, oldHref) {
          return oldHref+"?Authorization="+token;
        });
        $('a[id^="letterdel-"]').attr('href', function(index, oldHref) {
          return oldHref+"?Authorization="+token;
        });
        $("#validForm").validate({
          submitHandler: function (form, event) {
            event.preventDefault();
            const token = sessionStorage.getItem("accessToken");
            axios
              .post(form.action, $(form).serializeJSON(), {
                headers: {
                  "Tenant-Id": Cms.getTenantId(),
                  Authorization: "Bearer " + token,
                },
              })
              .then(function (response) {
                var data = response.data;
                if (data.code !== 0) {
                  alertTip(data.msg);
                } else {
                  successTip();
                }
                location.reload();
              });
          },
        });
      });
      function loginedCallBack(response) {
        $("#nickname").val(response.data.data.nickname);
        $("#email").val(response.data.data.email);
        $("#sex").val(response.data.data.sex);
        $("#mobile").val(response.data.data.mobile);
        $("#sex option[value='" + response.data.data.sex + "']").attr(
          "selected",
          "selected"
        );
      }
    </script>
  </body>
</html>
[/#escape]
